<template>
	<view class="feedback">
		<view class="feedback-m">
			<textarea type="text" v-model="content" style="border: 1rpx solid #eaeaea;padding: 10rpx;" class="textarea"
				placeholder="请输入您要反馈的问题" />
		</view>
		<button class="feedback-btn" @tap="submit">提交</button>
	</view>
</template>

<script>
	import form from '@/utils/validation.js';
	import {
		feedbackAdd
	} from '@/services/user.js';
	export default {
		data() {
			return {
				content: '',
				fromData: {
					type: 2, //1留言反馈  2联系客服
					msg: ''
				}
			};
		},
		onLoad() {},
		onShow() {},
		methods: {
			async submit() {
				let rules = [{
					name: 'content',
					rule: ['required', 'minLength:5', 'maxLength:500'],
					msg: ['请输入问题描述', '问题描述必须8个或以上字符', '问题描述不能超过500个字符']
				}];
				let formData = {
					content: this.content
				};
				let checkRes = form.validation(formData, rules);
				if (!checkRes) {
					await feedbackAdd({
						content: this.content,
					}, {
						loading: true
					});
					uni.showToast({
						title: '提交成功',
						icon: 'none'
					})
					setTimeout(v => {
						uni.navigateBack({});
					}, 1000);
				}
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #ffffff;

		.feedback-m {
			padding: 30rpx;

			.textarea {
				width: 680rpx;
				margin: 0 auto;

			}
		}

		.feedback-btn {
			display: flex;
			justify-content: center;
			align-items: center;
			background-color: $uni-color-primary;
			color: #fff;
			border-radius: 10rpx;
			height: 80rpx;
			margin: 50rpx auto 0;
			width: 690rpx;
		}

	}
</style>
